Skip to main content

Configuring BSNL SIP Trunk (SIP PRI) on Asterisk with OpenVPN | A Complete PJSIP Guide (2026 Edition)

 


A practical, production-ready guide to configuring BSNL SIP PRI (IMS SIP Trunk) on modern Asterisk (PJSIP) with OpenVPN. Covers authentication, routing, user_eq_phone, scoring logic, debugging, and real-world carrier behavior.

BSNL now delivers SIP PRI over FTTH fiber using IMS-based SIP signaling routed through VPN (OpenVPN or SoftEther).

Key realities:

  • SIP Proxy is reachable only via VPN
  • SIP authentication may use:
  • IMS expects proper user=phone format
  • RTP may traverse different subnets

If your PBX doesn’t support OpenVPN natively, you must deploy a router or gateway device that does.

Article content

🛠 Step 1 – Configure OpenVPN

BSNL provides:

VPN Server Primary IP
VPN Server Secondary IP
Virtual IP (Client)
Gateway
Mask 

After connecting:

ip addr show tun0
ip route
ping 10.x.x.x  # SIP Proxy 

Ensure:

  • VPN interface is UP
  • Route to SIP proxy goes through VPN
  • SIP proxy is reachable


🧩 Step 2 – Configure BSNL SIP Trunk (PJSIP – NOT chan_sip)

Modern Asterisk uses PJSIP, not sip.conf.

Below is a production-ready configuration.


🔐 AUTH Section

[bsnl_auth]
type=auth
auth_type=userpass
username=+91XXXXXXXXXX
password=yourpassword 

📍 AOR Section

If REGISTER trunk:

[bsnl_aor]
type=aor
max_contacts=1
qualify_frequency=30 

If IP-auth trunk:

contact=sip:10.19.15.1:5060 

☎ Endpoint Section (CRITICAL)

[bsnl_endpoint]
type=endpoint
transport=transport-udp
context=from-trunk
disallow=all
allow=ulaw,alaw
auth=bsnl_auth
aors=bsnl_aor
from_user=+91XXXXXXXXXX
from_domain=upe.stbi.ims.bsnl.in
outbound_proxy=sip:10.19.15.1:5060;lr
user_eq_phone=yes
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes
dtmf_mode=rfc4733
timers=yes 

🔎 Why user_eq_phone=yes Is Mandatory for India/BSNL

IMS expects:

sip:+91XXXXXXXXXX@domain;user=phone 

Without user_eq_phone=yes, calls may fail even if registration succeeds.


🔁 Registration Block (If Required)

[reg_bsnl]
type=registration
outbound_auth=bsnl_auth
server_uri=sip:upe.stbi.ims.bsnl.in
client_uri=sip:+91XXXXXXXXXX@upe.stbi.ims.bsnl.in
contact_user=+91XXXXXXXXXX
retry_interval=60
expiration=120 

📞 Dialplan Configuration

Inbound

[from-trunk]
exten => +91XXXXXXXXXX,1,NoOp(Incoming BSNL Call)
 same => n,Dial(PJSIP/1001) 

Outbound

[outbound]
exten => _9.,1,NoOp(Outgoing via BSNL)
 same => n,Dial(PJSIP/${EXTEN:1}@bsnl_endpoint) 

🎵 Codec & Media Recommendations

✔ Use only:

ulaw
alaw 

✔ DTMF:

rfc4733 

Avoid transcoding unless absolutely required.


🔍 Debugging & Troubleshooting

Enable SIP debugging:

asterisk -rvvv
pjsip set logger on
pjsip show registrations
pjsip show endpoint bsnl_endpoint
pjsip show contacts 

Network-level debugging:

tcpdump -i tun0 port 5060 

📊 Carrier-Grade Monitoring Best Practice

In production systems:

  • Don’t rely only on REGISTER
  • Score trunk health using:
  • Avoid marking trunk DOWN on single failure
  • Use grace period logic

This avoids false negatives in telecom environments.


⚠ Common BSNL SIP Issues

ProblemCauseRegistered but no outgoing callsMissing user_eq_phone=yes403 ForbiddenWrong From headerNo audioRTP routing via wrong interfaceFlapping trunkVPN route instabilityWorks after reload onlyIncorrect AOR / section ID mismatch


🧠 Final Thoughts

BSNL SIP PRI is not “just another SIP trunk.” It behaves like IMS telecom infrastructure.

To deploy it correctly:

  • Understand VPN routing
  • Use proper PJSIP sections
  • Align endpoint IDs correctly
  • Format Indian numbers properly
  • Monitor with carrier-grade logic

When configured properly, it is extremely stable.


If you're building multi-tenant PBX systems, telecom billing engines, or AI-driven calling platforms, mastering IMS-style SIP trunks is essential.

Happy Building 🚀

AffordableAI, Cybersecurity, IPPBX , CCaaS Mobile VOIP & Web Dev Consulting – Start at $5!

Name

Email *

Message *